package com.zhudi.develop_demo_as.utils;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zhudi.develop_demo_as.R;

/**
 * 
 * @author zhudi 设置图片
 */
public class MyImageLoader {
	public static DisplayImageOptions imageOptions;

	public static void loadImage(String url, ImageView image) {
		imageOptions = new DisplayImageOptions.Builder().cacheOnDisk(true)
				.cacheInMemory(true)
				.showImageOnFail(R.drawable.ic_daren)
				.showImageOnLoading(R.drawable.ic_daren)
				.showImageForEmptyUri(R.drawable.ic_daren)
				//.imageScaleType(ImageScaleType.EXACTLY)
				.cacheInMemory()
				.cacheOnDisc()
				.bitmapConfig(Bitmap.Config.RGB_565)
				.build();
		ImageLoader.getInstance().displayImage(url, image, imageOptions);
	}

	public static void loadImage(String url, ImageView image,int resources) {
		imageOptions = new DisplayImageOptions.Builder().cacheOnDisk(true)
				.cacheInMemory(true)
				.showImageOnFail(resources)
				.showImageOnLoading(resources)
				.showImageForEmptyUri(resources)
				//.imageScaleType(ImageScaleType.EXACTLY)
				.cacheInMemory()
				.cacheOnDisc()
				.bitmapConfig(Bitmap.Config.RGB_565)
				.build();
		ImageLoader.getInstance().displayImage(url, image, imageOptions);
	}
}
